package environment;

import java.util.Random;

public class Genotype {
	public static Random random = new Random();
	private int [] genotype;
	public Genotype(int [] genotype){
		this.genotype = genotype;
	}
	
	
	/**
	 * @return a random Genotype.
	 */
	public static Genotype randomGenotype() {
		int[] ansArr = new int[7];
		for (int i = 0; i < 7; i++) {
			ansArr[i] = (int) (Math.random() * 7);
		}
		return new Genotype(ansArr);
	}

	public void mutate() {
		if (random.nextDouble() < Constants.mutationProbability) {
			int index = random.nextInt(7);
			this.genotype[index] = random.nextInt(4);
		}
	}

	public String toString() {
		String ans = "[";
		for (int i = 0; i < genotype.length; i++) {
			ans += " " + genotype[i];
		}
		ans += "]";
		return ans;
	}

	public int indexAt(Integer index) {

		return this.genotype[index];
	}

	public void set(Integer index, int temp) {
		this.genotype[index] = temp;
	}

}
